package org.genntii.warehousesystem.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.genntii.warehousesystem.domain.entity.GoodsWarehouse;

import java.util.List;

@Mapper
public interface GoodsWarehouseMapper extends BaseMapper<GoodsWarehouse> {

    @Select("select goods_id from goods_warehouse where warehouse_id = #{warehouseId}")
    List<Integer> selectGoodsByWarehouse(@Param("warehouseId")int warehouseId);

    @Select("select * from goods_warehouse where goods_id = #{goodsId}")
    List<GoodsWarehouse> selectGoodsWarehouseByGoodsId(@Param("goodsId")int goodsId);

    @Select("select * from goods_warehouse where goods_id = #{goodsId} and warehouse_id = #{warehouseId}")
    GoodsWarehouse selectNum(@Param("goodsId") int goodsId, @Param("warehouseId")int warehouseId);

    @Update("update goods_warehouse set goods_num = #{num} where id = #{id}")
    void setNum(@Param("num") int num,@Param("id")int id);

    @Select("select * from goods_warehouse where goods_id = #{goodsId}")
    List<GoodsWarehouse> listGoodsWarehouse(@Param("goodsId")int goodsId);

}
